package tables

import (
	"github.com/GoAdminGroup/go-admin/context"
	"github.com/GoAdminGroup/go-admin/modules/db"
	"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table"
	"github.com/GoAdminGroup/go-admin/template/types/form"
)

func GetAylinkTable(ctx *context.Context) table.Table {

	ayLink := table.NewDefaultTable(ctx, table.DefaultConfigWithDriverAndConnection("sqlite", "pbootcms"))

	info := ayLink.GetInfo()

	info.AddField("Id", "id", db.Integer).
		FieldSortable()
	info.AddField("区域编码", "acode", db.Text)
	info.AddField("分组序号", "gid", db.Integer)
	info.AddField("链接名称", "name", db.Text)
	info.AddField("跳转链接", "link", db.Text)
	info.AddField("图片地址", "logo", db.Text)
	info.AddField("排序", "sorting", db.Integer)
	info.AddField("创建人员", "create_user", db.Text)
	info.AddField("更新人员", "update_user", db.Text)
	info.AddField("创建时间", "create_time", db.Text)
	info.AddField("修改时间", "update_time", db.Text)

	info.SetTable("ay_link").SetTitle("链接").SetDescription("链接")

	formList := ayLink.GetForm()
	formList.AddField("Id", "id", db.Integer, form.Default).
		FieldDisableWhenCreate()
	formList.AddField("区域编码", "acode", db.Text, form.SelectSingle)
	formList.AddField("分组序号", "gid", db.Integer, form.Number)
	formList.AddField("链接名称", "name", db.Text, form.Text)
	formList.AddField("跳转链接", "link", db.Text, form.Text)
	formList.AddField("图片地址", "logo", db.Text, form.Text)
	formList.AddField("排序", "sorting", db.Integer, form.Number).
		FieldDefault("255")
	formList.AddField("创建人员", "create_user", db.Text, form.Text)
	formList.AddField("创建时间", "update_user", db.Text, form.Text)
	formList.AddField("创建时间", "create_time", db.Text, form.Text)
	formList.AddField("修改时间", "update_time", db.Text, form.Text)

	formList.SetTable("ay_link").SetTitle("编辑链接").SetDescription("编辑链接")

	return ayLink
}
